<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--suppress ALL-->
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/laydate/laydate.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="../users/userList.html">系统管理</a></li>
    <li><a href="deptList.html">部门管理</a></li>
    <li><a href="#">添加</a></li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>部门信息</span></div>
  <ul class="forminfo">
    <li>
      <label>部门编号</label>
      <input name="deptId" type="text" class="dfinput"/>
      <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>部门名称</label>
      <input name="deptName" type="text" class="dfinput" />
      <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>所属区域</label>
      <select class="dfselect" name="pName">
        <option>请选择</option>
          <option th:each="sysProvince:${Provinces}" th:text="${sysProvince.pName}"></option>
      </select>
      省
      <select class="dfselect" name="cName">
        <option>请选择</option>
        <option th:each="sysCity:${Cities}" th:text="${sysCity.cName}">请选择</option>

      </select>
      市
      <i>必选</i>
    </li>


    <li>
      <label>&nbsp;</label>
      <input name="save" type="button" class="btn" value="确认保存"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回"  onclick="window.history.go(-1);"/>
    </li>
  </ul>
</div>


<script type="text/javascript">


  $(function () {
    $("input[name='save']").click(function () {
      /*alert($("select[name='deptName']>option:selected").val());
      alert(jobName);*/
      // if (utelephone!='')
      let data={
        "deptId":$("input[name='deptId']").val(),
        "deptName":$("input[name='deptName']").val(),
        "pName":$("select[name='pName']>option:selected").val(),
        "cName":$("select[name='cName']>option:selected").val()
      }

      $.ajax({
        url:"/sys/addDept",
        type:"POST",
        data:data,
        resultType:"JSON",
        success:function (result) {
          if(result<0){
            alert("保存失败")
          }else {
            alert("保存成功");
            location.href="/sys/deptList";
          }

        }


      })
    });
  });
</script>
</body>
</html>

